package com.yunze.apiCommon.upstreamAPI.SDJinDouYun;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yunze.apiCommon.utils.HttpUtil;
import com.yunze.apiCommon.utils.MD5Util;

import java.util.Map;

/**
 * 金斗云
 */
public class JinDouYun_Api {


	//构造赋值
	public JinDouYun_Api(Map<String, Object> init_map){
		user_id = init_map.get("cd_username").toString(); //根据用户的 数据获取 id
		key = init_map.get("cd_key").toString(); // 获取key
    }

	// 请求地址
	protected static  String server_Ip = "http://api.m2m-10086.cn:32003";
	//id
	public static String user_id = null;
	public  static String key =null;

	public static String getSign(long times){ //获取sign

		String sign = MD5Util.MD5Encode("userId="+user_id+"&apikey="+key+"&times="+times).toUpperCase();
		return sign;
	}

	public static void main(String[] args) {

		// 请求地址
		String server_Ip = "http://api.m2m-10086.cn:32003/api/v1/getChaxun?";//http://api.m2m-10086.cn:32003/api/v1/getChaxun?
		//id
		String xx = "2339";
		String xs ="8f7abefd17e6345ce25a445e03687d8f";
		user_id=xx;
		key=xs;

		long times = System.currentTimeMillis() / 1000;
		System.out.println(times);
		//String sign = MD5Util.MD5Encode("userId=" + user_id + "&apikey=" + key + "&times=" + times).toUpperCase();
		String sign = getSign(times);
		//System.out.println(times);
//		String pinUrl  =  server_Ip +"?"+ Pamr;
//		String res = HttpUtil.get(pinUrl);
		System.out.println(sign);
		// 流量::http://域名/api/v1/getChaxun?userId=10000&cardno=1064925994085&times=1484139646&sign=9E1A28E0377DA2AFF3E55707657485EF
		String cardno =
				"898604B61522C0030000";
		String pinUrl = server_Ip + "userId=" + user_id +"&cardno="+cardno+"&times="+times+"&sign="+sign;
		System.out.println("请求地址参数:");
		System.out.println(pinUrl);
		String res = HttpUtil.get(pinUrl);
		//System.out.println(res);
		JSONObject jsonObject = JSON.parseObject(res);
		System.out.println(jsonObject);


	}




}
